package com.kg.fiber.service.pcie8622;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import com.ivan.toolkit.common.Configs;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
@NoArgsConstructor
public class Pcie8622Config {
	
	public static Configs.Instance<Pcie8622Config> instance = 
			new Configs.Instance<Pcie8622Config>(Pcie8622Config.class, true);	

	/**
	 * Pcie8622卡的逻辑号，示例程序�?0，这里默认为0
	 */
	@XmlAttribute
	@Setter @Getter
	private int logicId = 0;
	
	/**
	// rangechan
	<P>public static final int PCIE8622_GAINS_1MULT = 0x00;  // 1倍增�?
	<P>public static final int PCIE8622_GAINS_2MULT = 0x01;  // 2倍增�?
	<P>public static final int PCIE8622_GAINS_5MULT = 0x02;  // 4倍增�?
	<P>public static final int PCIE8622_GAINS_10MULT = 0x03; // 8倍增�?
	 */
	@XmlAttribute
	@Setter @Getter
	private int gains = Pcie8622Sdk.PCIE8622_GAINS_1MULT;
	
	/**
	 * // 首�?�道[0,31]
	 */
	@XmlAttribute
	@Setter @Getter
	private int channelFirst = 0;
	
	/**
	 * 末�?�道[0,31],要求末�?�道必须大于或等于首通道
	 */
	@XmlAttribute
	@Setter @Getter
	private int channelLast = 0;
	
	/**
	// ad_mode AD 采样模式
	<P>public static final int PCIE8622_ADMODE_SEQUENCE = 0x00; // 连续采集模式
	<P>public static final int PCIE8622_ADMODE_GROUP = 0x01;    // 分组采集模式
	 */
	@XmlAttribute
	@Setter @Getter
	private int adMode = Pcie8622Sdk.PCIE8622_ADMODE_SEQUENCE;
	
	/**
	// triggermode
	<P>public static final int PCIE8622_TRIGMODE_SOFT = 0x00; // 软件触发(属于内触�?)
	<P>public static final int PCIE8622_TRIGMODE_POST = 0x01; // 硬件后触�?(属于外触�?)
	 */
	@XmlAttribute
	@Setter @Getter
	private int trigerMode = Pcie8622Sdk.PCIE8622_TRIGMODE_SOFT;
	
	/**
	// triggersource 
	<P>public static final int PCIE8622_TRIGSRC_ATR = 0x01; // 选择 ATR 作为触发�?
	<P>public static final int PCIE8622_TRIGSRC_DTR = 0x02; // 选择 DTR 作为触发�?
	 */
	@XmlAttribute
	@Setter @Getter
	private int trigerSource = Pcie8622Sdk.PCIE8622_TRIGSRC_ATR;
	
	/**
	// trigertype
	<P>public static final int PCIE8622_TRIGTYPE_EDGE = 0x00;  // 边沿触发
	<P>public static final int PCIE8622_TRIGTYPE_PULSE = 0x01; // 脉冲触发(电平)
	 */
	@XmlAttribute
	@Setter @Getter
	private int trigerType = Pcie8622Sdk.PCIE8622_TRIGTYPE_EDGE;
	
	/**
	// triggerdir
	<P>public static final int PCIE8622_TRIGDIR_NEGATIVE = 0x00;    // 负向触发(低脉�?/下降沿触�?)
	<P>public static final int PCIE8622_TRIGDIR_POSITIVE = 0x01;    // 正向触发(高脉�?/上升沿触�?)
	<P>public static final int PCIE8622_TRIGDIR_POSIT_NEGAT = 0x02; // 正负方向均有�?
	 */	
	@XmlAttribute
	@Setter @Getter
	private int trigerDir = Pcie8622Sdk.PCIE8622_TRIGDIR_NEGATIVE;
	
	/**
	// clocksource	
	<P>public static final int PCIE8622_CLOCKSRC_IN = 0x00;  // 内部时钟定时触发
	<P>public static final int PCIE8622_CLOCKSRC_OUT = 0x01; // 外部时钟定时触发
	 */		
	@XmlAttribute
	@Setter @Getter
	private int clockSource = Pcie8622Sdk.PCIE8622_CLOCKSRC_IN;
	
	/**
	// bclockoutput
	<P>public static final int PCIE8622_CLOCKOUT_DISABLE = 0x00; // 禁止本卡上的自带时钟向外输出
	<P>public static final int PCIE8622_CLOCKOUT_ENABLE = 0x01;  // 允许本卡上的自带时钟向外输出
	 */		
	@XmlAttribute
	@Setter @Getter
	private int clockOutput = Pcie8622Sdk.PCIE8622_CLOCKOUT_DISABLE;
	
	/**
	// groundingmode	
	<P>public static final int PCIE8622_GNDMODE_SE = 0x00; // 单端方式(SE:Single end)
	<P>public static final int PCIE8622_GNDMODE_DI = 0x01; // 双端方式(DI:Differential)
	 */			
	@XmlAttribute
	@Setter @Getter
	private int groundingMode = Pcie8622Sdk.PCIE8622_GNDMODE_SE;
	
	/**
	 * // 采集频率,单位为Hz
	 */
	@XmlAttribute
	@Setter @Getter
	private int frequency = 250000;
	
	/**
	 * // 分组时的组间间隔(单位：微�?)[1, 419430]
	 */
	@XmlAttribute
	@Setter @Getter
	private int groupInterval = 10;
	
	/**
	 * // 组内循环次数[1, 65535]
	 */
	@XmlAttribute
	@Setter @Getter
	private int groupLoops = 1;
	
	/**
	// input_range
	<P>public static final int PCIE8622_INPUT_N10000_P10000mV = 0x00; // ±10000mV
	<P>public static final int PCIE8622_INPUT_N5000_P5000mV = 0x01;   // ±5000mV
	<P>public static final int PCIE8622_INPUT_N2500_P2500mV = 0x02;   // ±2500mV
	<P>public static final int PCIE8622_INPUT_0_P10000mV = 0x03;      // 0~10000mV
	<P>public static final int PCIE8622_INPUT_0_P5000mV = 0x04;       // 0~5000mV
	 */
	@XmlAttribute
	@Setter @Getter
	private int inputRange = Pcie8622Sdk.PCIE8622_INPUT_0_P5000mV;
	
	/**
	 * // 触发电平(0mV ~10000mV)
	 */
	@XmlAttribute
	@Setter @Getter
	private int trigLevelVolt = 0;
	
	/*
		public int FirstChannel;   // 首�?�道[0,31]
		public int Gains;          // 增益设置
		public int LastChannel;    // 末�?�道[0,31],要求末�?�道必须大于或等于首通道
		public int ADMode;         // AD模式选择(连续/分组方式)
		public int TriggerMode;    // 触发模式选择
		public int TriggerSource;  // 触发源�?�择
		public int TriggerType;    // 触发类型选择(边沿触发/脉冲触发)
		public int TriggerDir;     // 触发方向选择(正向/负向触发)
		public int ClockSource;    // 时钟源�?�择(�?/外时钟源)
		public int bClockOutput;   // 允许时钟输出
		public int GroundingMode;  // 接地方式(单端或双端�?�择)
		public int Frequency;      // 采集频率,单位为Hz
		public int GroupInterval;  // 分组时的组间间隔(单位：微�?)[1, 419430]
		public int LoopsOfGroup;   // 组内循环次数[1, 65535]
		public int InputRange;     // 模拟量输入量程范�?
		public int TrigLevelVolt;  // 触发电平(0mV ~10000mV)
	 */
	
	
	/**
	 * // 数据接收模式�?0：非空模式，1：半满模�?
	 */
	@XmlAttribute
	@Setter @Getter
	private int receiveMode = 1;
	
	public boolean isHarfReceiveMode() {
		return receiveMode == 1;
	}
	
	/**
	 * // 数据接收间隔，单位：毫秒，每次接收数据操作中sleep的毫秒数�?0表示没有间隔
	 */
	@XmlAttribute
	@Setter @Getter
	private long receiveInterval = 1;
}
